<!DOCTYPE html>
<html lang="en">
   <head>
      <meta charset="UTF-8">
      <title>存款取款</title>
   </head>
   <body>
      <script>
         let money = 100
         let flag = true
         while (flag) {
            let type = +prompt(`
            请输入操作类型:
            1:存款
            2:取款
            3:查询余额
            4:退出
            `)
            // if (type === 4) {
            //    break
            // }
            switch (type) {
               case 1:
                  let add = +prompt('请输入存款金额:')
                  money += add
                  break
               case 2:
                  let red = +prompt('请输入取款金额:')
                  if (red > money) {
                     alert('余额不足')
                  } else {
                     money -= red
                  }
                  break
               case 3:
                  alert(`余额:${money}`)
                  break
               case 4:
                  flag = false
                  break
               default:
                  alert('输入有误')
            }
         }
      </script>
   </body>
</html>